<%--
  Created by IntelliJ IDEA.
  User: 皮
  Date: 2023/5/13
  Time: 17:11
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>添加信息</title>
</head>
<body>
<form action="${pageContext.request.contextPath}/person/add" id="mysql" method="post">
    姓名:<input type="text" name="name"><br>
    性别:<input type="text" name="sex"><br>
    年龄:<input type="text" name="age"><br>
    等级:<input type="text" name="rank"><br>
    所在部门:<input type="text" name="department"><br>
    <input type="button" value="提交" onclick="add()">
</form>

<script src="${pageContext.request.contextPath}/js/jquery.js"></script>

<script>
    add = function () {
        var name = $("[name=name]").val();
        var sex = $("[name=sex]").val();
        var age = $("[name=age]").val();
        var rank = $("[name=rank]").val();
        var department = $("[department=department]").val();
        if (name == "" || sex == "" || age == "" || rank == "" || department == "") {
            alert("请填写完整信息");
            return;
        } else {
            $("#mysql").submit();
        }
    }
</script>
</body>
</html>
